
\begin{frame}
\frametitle{Matplotlib}
\reference{
More info: \url{http://matplotlib.sourceforge.net/}
}
\begin{center}
\includegraphics[width=0.75\linewidth]{Logo/matplotlib}
\end{center}
\begin{itemize}
  \item Matplotlib provides plotting capabilities that are similar to MATLAB.
  \item Syntax is the same or similar to MATLAB in most cases.
  \item Matplotlib has some advantages over MATLAB plots
  \begin{itemize}
    \item Handles TeX equation typesetting within plots.
    \item Easy export to PDF using vector graphics.
    \item Plots often look nicer than MATLAB plots.
  \end{itemize}
  \item The above logo is actually a matplotlib plot.
\end{itemize}
\end{frame}


\begin{frame}
\frametitle{Matplotlib Example Plots}
\reference{
More info: \url{http://matplotlib.sourceforge.net/users/screenshots.html}
}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=0.35\linewidth]{Plots/simple_plot} &
\includegraphics[width=0.35\linewidth]{Plots/histogram_demo} \\
\includegraphics[width=0.35\linewidth]{Plots/barchart_demo} &
\includegraphics[width=0.35\linewidth]{Plots/surface3d_demo} \\
\end{tabular}
\end{center}
\end{frame}


\begin{frame}[fragile]
\frametitle{Matplotlib Example Plots}
\reference{
More info: \url{http://matplotlib.sourceforge.net/users/screenshots.html}
}
\begin{columns}[c]
\column{0.50\textwidth}
\lstset{title=Examples/simple\_plot.py}
\lstlistingwithnumber{1}{11}{Examples/simple_plot.py}
\column{0.45\textwidth}
\includegraphics[width=\linewidth]{ScreenShot/matplotlib-simple}
\end{columns}
\begin{itemize}
  \item When not using pylab, these functions are found in \lstpy{matplotlib.pyplot}.
  \item The figure is not displayed until \lstpy{show()} is called.
\end{itemize}
\end{frame}


\begin{frame}[fragile]
\frametitle{Matplotlib Interactive Plotting}
\reference{
More info: \url{http://matplotlib.sourceforge.net/users/shell.html}
}
\begin{itemize}
  \item Matplotlib has an interactive plotting mode that updates plots after each command, and \lstpy{show()} is not needed.
  \item Interactive plotting is enabled with \lstpy{ion()} and disabled with \lstpy{ioff()}.
  \item Interactive mode is enabled automatically in Spyder and \texttt{ipython~--pylab}
\end{itemize}
\end{frame}


\subsection{Exercise 2}

\begin{frame}[fragile]
\frametitle{Exercise 2}
\framesubtitle{Plotting Lena with NumPy, SciPy, and Matplotlib}
\begin{textblock*}{47mm}(80mm,13mm)
  \hfill
\begin{lstlisting}
(*@\pyprompt@*) from scipy.misc import lena
(*@\pyprompt@*) imshow(lena())
(*@\pyprompt@*) gray()
\end{lstlisting}
\end{textblock*}
\begin{enumerate}
  \item Plot the ``Lena'' image.
  \item Plot the transpose of Lena using \lstpy{lena().T}.
  \item Plot 100 random points on top of Lena with x and y between 0 and 512 using \lstpy{rand} and \lstpy{scatter}.
  \item Plot a histogram of Lena with 100 bins using \lstpy{hist}.
        Hint: Flatten the image to 1-D using \lstpy{lena().flatten()}
  \item Plot Lena with a sub-matrix from (200,200) to (400,400) flipped horizontally.
        Hint: Create a modified image array using slice notation.
\end{enumerate}
\footnotesize
\begin{columns}[b]
\column{0.2\textwidth} \centering
\includegraphics[width=0.9\linewidth]{Plots/scipy-lena} \\ Part 1
\column{0.2\textwidth} \centering
\includegraphics[width=0.9\linewidth]{Plots/ex2-part2} \\ Part 2
\column{0.2\textwidth} \centering
\includegraphics[width=0.9\linewidth]{Plots/ex2-part3} \\ Part 3
\column{0.2\textwidth} \centering
\includegraphics[width=0.9\linewidth]{Plots/ex2-part4} \\ Part 4
\column{0.2\textwidth} \centering
\includegraphics[width=0.9\linewidth]{Plots/ex2-part5} \\ Part 5
\end{columns}
\end{frame}


\begin{frame}[fragile]
\frametitle{Exercise 2: Answers}
\framesubtitle{Plotting Lena with NumPy, SciPy, and Matplotlib}
\lstset{title=Exercises/Answers/ex2-answer.py}
\lstlistingwithnumber{7}{28}{Exercises/Answers/ex2-answer.py}
\end{frame}
